package com.zhuge_new.Dialog;

import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.flyco.dialog.widget.base.BaseDialog;
import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView;
import com.zhuge_new.Adapter.GatherDialogAdapter;
import com.zhuge_new.R;
import com.zhuge_new.bean.CardListBean;
import com.zhuge_new.bean.ExamBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/11/13.
 */

public class Gathering_Dialog extends BaseDialog<Gathering_Dialog> {


    private Context context;
    private List<ExamBean.CreditcardsBean> data=new ArrayList<>();
    private SwipeMenuRecyclerView recycle_list;
    private String check;
    private ImageView gatherdialog_state;
    private LinearLayout gatherdialog_entire;

    public Gathering_Dialog(Context context, List<ExamBean.CreditcardsBean> data,String check) {
        super(context);
        this.context=context;
        this.data=data;
        this.check=check;
    }

    @Override
    public View onCreateView() {
        View view=View.inflate(context, R.layout.dialog_gathering,null);
        gatherdialog_state = view.findViewById(R.id.gatherdialog_state);
        recycle_list = view.findViewById(R.id.recycle_list);
        recycle_list.setLayoutManager(new LinearLayoutManager(context));
        recycle_list.addItemDecoration(new DividerItemDecoration(context,DividerItemDecoration.VERTICAL));
        gatherdialog_entire =view.findViewById(R.id.gatherdialog_entire);
        return view;
    }

    @Override
    public void setUiBeforShow() {
        if (check.equals("0")){
            gatherdialog_state.setVisibility(View.VISIBLE);
        }else {
            gatherdialog_state.setVisibility(View.INVISIBLE);
        }
        GatherDialogAdapter adapter=new GatherDialogAdapter(context,data,check);
        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                dialogClickListener.onItemClick(data.get(position).getCreditcardId());
            }
        });
        recycle_list.setAdapter(adapter);
        gatherdialog_entire.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialogClickListener.onItemClick("0");
            }
        });

    }

    public DialogClickListener dialogClickListener=null;

    public interface DialogClickListener{
        void onItemClick(String CreditcardId);
    }

    public void setDialogClickListener(DialogClickListener dialogClickListener){
        this.dialogClickListener=dialogClickListener;
    }
}
